{% load i18n icons translations %}

{% for item in glossary %}
  <tr class="glossary-embed {% if "forbidden" in item.all_flags %}unclickable-row danger{% elif "read-only" in item.all_flags %}clickable-row warning{% else %}clickable-row{% endif %}"
      title=" {% if "forbidden" in item.all_flags %} {% translate "This translation is forbidden." %} {% elif "read-only" in item.all_flags %} {% translate "This term should not be translated." %} {% elif item.fuzzy %} {% translate "This translation needs editing." %}  {% else %} {% translate "Copy word into translation" %} {% endif %} ">
    <td class="source">{{ item.source }}</td>
    <td class="target">
      {% if "forbidden" in item.all_flags %}
        <span class="red forbidden-term">{% icon "cancel.svg" %}</span>
      {% endif %}
      {% if item.fuzzy %}
        <span class="red forbidden-term">{% icon "alert.svg" %}</span>
      {% endif %}
      {% format_unit_target unit value=item.target simple=True %}
    </td>
    <td>{% include "snippets/glossary-badge.html" with glossary=item.translation %}</td>
    <td>
      <a href="{{ item.get_absolute_url }}"
         class="btn btn-link btn-xs"
         title="{% translate "Edit glossary term" %}">{% icon "pencil.svg" %}</a>
    </td>
  </tr>
  {% if item.note %}
    <tr>
      <td colspan="4">
        <div class="alert alert-info" title="{% translate "Source string description" %}">{{ item.note }}</div>
      </td>
    </tr>
  {% endif %}
  {% if not item.is_source and item.explanation %}
    <tr>
      <td colspan="4">
        <div class="alert alert-info"
             title="{% translate "Glossary translation explanation" %}">{{ item.explanation|markdown }}</div>
      </td>
    </tr>
  {% endif %}
  {% if item.source_unit.explanation %}
    <tr>
      <td colspan="4">
        <div class="alert alert-info" title="{% translate "Glossary string explanation" %}">
          {{ item.source_unit.explanation|markdown }}
        </div>
      </td>
    </tr>
  {% endif %}
{% empty %}
  <tr>
    <td colspan="4">
      <em>{% translate "No related strings found in the glossary." %}</em>
    </td>
  </tr>
{% endfor %}
